#ifndef COM_H_
#define COM_H_

/******************************************************************************
 *  Include Files
 *****************************************************************************/
#include <stdint.h>
#include "DRV_MSCAN.h"

/******************************************************************************
 *  Macro Definitions
 *****************************************************************************/

/******************************************************************************
 *  Const Definitions
 *****************************************************************************/

/*****************************************************************************
 *  Type Definitions
 *****************************************************************************/
typedef enum {
  COM_BOOTLOADER_FRAMETYPE_OTHER = 0,
  COM_BOOTLOADER_FRAMETYPE_REQ = 1,
  COM_BOOTLOADER_FRAMETYPE_DATA = 2,
} COM_BOOTLOADER_FRAMETYPE;

typedef enum {
  COM_BOOTLOADER_INIT = 0,
  COM_BOOTLOADER_SHAKEHANDS_REQ = 1,
  COM_BOOTLOADER_SHAKEHANDS_RESP = 2,
  COM_BOOTLOADER_CHECKSUM_REQ = 3,
  COM_BOOTLOADER_CHECKSUM_RESP = 4,
  COM_BOOTLOADER_REBOOT_REQ = 5,
  COM_BOOTLOADER_REBOOT_RESP = 6,
  COM_BOOTLOADER_RESP = 0xFB,
  COM_BOOTLOADER_FLASH_ERASE = 0xFE,
  COM_BOOTLOADER_FLASH_PROG = 0xFF,
} COM_BOOTLOADER_WORKCOMMAND;

/*****************************************************************************
 *  Extern Variables
 *****************************************************************************/
extern uint8_t COM_Req;

/*****************************************************************************
 *  Function Prototypes
 *****************************************************************************/
extern void COM_Init(void);
extern uint8_t COM_CheckLink(void);
extern uint8_t COM_IsRxFull(void);
extern uint8_t COM_Read_Then_IsReq(void);
extern uint8_t COM_Read_Then_Check_Req(uint8_t Req);
extern void COM_Send_Resp(uint8_t Resp);
extern void COM_Send_CheckSum(void);
extern uint8_t COM_Data2Buf(uint8_t Data_Buf[], uint8_t Data_Buf_cnt,
                            uint8_t DATABUFMAX);
extern void COM_Send_Warning(void);

#endif /* COM_H_ */
